package com.enjoyor.soa.traffic.server.tpcms.dubbo.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.enjoyor.soa.traffic.api.dto.tpcms.InfoWhiteListDto;
import com.enjoyor.soa.traffic.api.service.dubbo.tpcms.IDubboWhiteListService;
import com.enjoyor.soa.traffic.core.tpcms.domain.InfoWhiteList;
import com.enjoyor.soa.traffic.core.tpcms.service.IWhiteListService;
import com.enjoyor.soa.traffic.util.helper.ReflectHelper;
import com.enjoyor.soa.traffic.util.pojo.Page;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

/**
 * 白名单车辆信息维护接口
 * 
 * @author zsy 2018年5月2日
 *
 */
@SuppressWarnings("rawtypes")
@Service(version = "1.0.0", timeout = 4000)
public class DubboWhiteListService implements IDubboWhiteListService {

    @Autowired
    private IWhiteListService whiteListService;

    /**
     * 获取白名单车辆信息列表
     */
    @Override
    public ResultPojo getWhiteListPage(Page page) {
        return new ResultPojo(whiteListService.getWhiteListPage(page));
    }

    /**
     * 获取白名单车辆信息列表
     */
    @Override
    public ResultPojo getWhiteListList(String whiteListId, String licenseNumber, String licenseTypeId,
            String vehicleTypeId, String funTypeId, String vehicleDept) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("whiteListId", whiteListId);
        map.put("licenseNumber", licenseNumber);
        map.put("licenseTypeId", licenseTypeId);
        map.put("vehicleTypeId", vehicleTypeId);
        map.put("funTypeId", funTypeId);
        map.put("vehicleDept", vehicleDept);
        return new ResultPojo(whiteListService.getWhiteListList(map));
    }

    /**
     * 新增白名单车辆
     */
    @Override
    public ResultPojo insertWhiteList(InfoWhiteListDto infoWhiteList, String userName) {
        return new ResultPojo(whiteListService
                .insertWhiteList(ReflectHelper.beanToBean(infoWhiteList, InfoWhiteList.class), userName));
    }

    /**
     * 修改白名单车辆信息
     */
    @Override
    public ResultPojo editWhiteList(InfoWhiteListDto infoWhiteList, String userName) {
        whiteListService.editWhiteList(ReflectHelper.beanToBean(infoWhiteList, InfoWhiteList.class), userName);
        return new ResultPojo();
    }

    /**
     * 删除白名单车辆信息
     */
    @Override
    public ResultPojo deleteWhiteList(String whiteListId, String userName) {
        whiteListService.deleteWhiteList(whiteListId, userName);
        return new ResultPojo();
    }

    /**
     * 批量导入白名单车辆
     */
    @Override
    public ResultPojo insertBatch(List<InfoWhiteListDto> whiteLists, String userName) {
        return new ResultPojo(
                whiteListService.insertBatch(ReflectHelper.listToList(whiteLists, InfoWhiteList.class), userName));
    }

}
